package com.andong.controller;



import com.andong.annotations.AccessControl;
import com.andong.domain.entity.RegisterBooking;
import com.andong.domain.pojo.PageResult;
import com.andong.domain.pojo.Result;
import com.andong.service.RegisterBookingService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.time.LocalDate;

import static com.andong.utils.SystemConstant.*;

/**
 * 学员预约注册表(RegisterBooking)表控制层
 *
 * @author makejava
 * @since 2024-01-13 16:35:26
 */
@RestController
@RequestMapping("/register")
public class RegisterBookingController {
    /**
     * 服务对象
     */
    @Resource
    private RegisterBookingService registerBookingService;

    @PostMapping("/add")
    public Result add(@RequestBody RegisterBooking registerBooking, String code) throws Exception {
        return registerBookingService.add(registerBooking, code);
    }

    @PutMapping()
    @AccessControl(roles = {ADMIN, SUPER_ADMIN}, permission = "注册管理")
    public Result updateStatus(Long id, Integer status) throws Exception {
        return registerBookingService.updateStatus(id, status);
    }

    @GetMapping("/list")
    @AccessControl(roles = {STUDENT, ADMIN, SUPER_ADMIN}, permission = "注册管理")
    public Result list(@RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer pageSize,
                       String name, Integer gender, Integer licenseType) {
        PageResult pageResult = registerBookingService.queryList(page, pageSize, name, gender, licenseType);
        return Result.success(pageResult);
    }
}

